package com.hqyj.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hqyj.dao.LogInfoMapper;
import com.hqyj.pojo.KaoQin;
import com.hqyj.pojo.LogInfo;
import com.hqyj.service.LogInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;

@Service
public class LogInfoServiceImpl implements LogInfoService {

    @Autowired
    LogInfoMapper logInfoMapper;
    @Override
    public HashMap<String, Object> selectAll(LogInfo logInfo) {
        HashMap<String, Object> map = new HashMap<String, Object>();
        //1 设置分页参数：页码和条数
        PageHelper.startPage(logInfo.getPage(),logInfo.getRow());
        //2 查询结果集合
        List<LogInfo> list =logInfoMapper.selectAll();

        // 3 创建分页对象
        PageInfo<LogInfo> pageInfo = new PageInfo<LogInfo>(list);


        map.put("total",pageInfo.getTotal());
        map.put("pages",pageInfo.getPages());
        map.put("endPage",pageInfo.getNavigateLastPage());
        map.put("curPage",logInfo.getPage());
        map.put("data",pageInfo.getList());
        return map;
    }
}
